<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

<script type="text/javascript">

//工厂模式
function createBook(name, time, type) {
	//创建一个对象
	var o = new Object();
	o.name = name;
	o.time = time;
	o.type = type;
	o.getName = function() {
		console.error(this.name);
	};
	return o;
};

var book1 = createBook('js book', 2014, 'js');
var book2 = createBook('css book', 2015, 'css');

book1.getName();
book2.getName();

</script>

</body>
</html>